home *** CD-ROM | disk | FTP | other *** search
/ CD-ROM Data 2002 May / CD Rom Data Mayıs 2002.iso / Freeware / Blitz Basic / data1.cab / Support / help / samples / Ants.bb next >
Encoding:
Text File  |  2002-04-10  |  1.2 KB  |  65 lines

  1. ;Ants
  2. ;copyright ⌐2000 EdzUp
  3. ;written by Ed Upton
  4.  
  5. ;PLEASE NOTE GEORGE ANTS DOES NOT INCLUDE SHEEP IN ANY WAY ;)
  6.  
  7. ;adjust this to your preference
  8. Global antnum=50
  9.  
  10. ;init graphics
  11. Graphics 640,480
  12. ;SetBuffer BackBuffer()
  13.  
  14. Type blob
  15.  Field x,y,f
  16.  Field r,g,b
  17. End Type
  18.  
  19. PositionAnt()
  20.  
  21. While Not KeyDown(1)
  22.  MoveAnt()
  23. ; Flip
  24. Wend
  25. End
  26.  
  27. Function PositionAnt()
  28.  For n=0 To antnum
  29.   ant.blob = New blob
  30.   ant\x=Rnd(640)
  31.   ant\y=Rnd(480)
  32.   ant\f=Rnd(3)
  33.   ant\r=Rnd(200)+55
  34.   ant\g=Rnd(200)+55
  35.   ant\b=Rnd(200)+55
  36.  Next
  37. End Function
  38.  
  39. Function MoveAnt()
  40.  a=0
  41.  For ant.blob=Each blob
  42.   If ant\f=0 Then ant\y=ant\y-1
  43.   If ant\f=1 Then ant\x=ant\x+1
  44.   If ant\f=2 Then ant\y=ant\y+1
  45.   If ant\f=3 Then ant\x=ant\x-1
  46.   If ant\x<0 Then ant\x=639
  47.   If ant\x>639 Then ant\x=0
  48.   If ant\y<0 Then ant\y=479
  49.   If ant\y>479 Then ant\y=0
  50.   GetColor ant\x,ant\y
  51.   If ColorRed()=0 And ColorGreen()=0 And ColorBlue()=0
  52.    Color ant\r,ant\g,ant\b
  53.    Plot ant\x,ant\y
  54.    ant\f=ant\f-1
  55.   Else
  56.    Color 0,0,0
  57.    Plot ant\x,ant\y
  58.    ant\f=ant\f+1
  59.   EndIf
  60.   If ant\f<0 Then ant\f=3
  61.   If ant\f>3 Then ant\f=0
  62.   If a=0 Then Color 255,0,0
  63.   a=a+1
  64.  Next
  65. End Function